import Taro from '@tarojs/taro'

/**
 * get method
 * @param {*} url 
 * @param {*} data 
 */
export const getJSON = (url, data) => {
  Taro.showLoading()
  return Taro.request({url, data, method: 'GET'}).then(res => {
    Taro.hideLoading()
    return res
  })
}

/**
 * post method
 * @param {*} url 
 * @param {*} data 
 */
export const postJSON = (url, data) => {
  Taro.showLoading()
  return Taro.request({
    header: {'content-type': 'application/json'},
    url, 
    data, 
    method: 'POST'
  }).then(res => {
    Taro.hideLoading()
    return res
  })
}

